﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HotelManger2012
{
    public partial class Form6WolnePokoje : Form
    {
        Form1Manager form = new Form1Manager();
        Form2Rejestruj form2 = new Form2Rejestruj();
        List<int> pokoje = new List<int>();
        List<int> wolnepokoje = new List<int>();
        public static int nrpokoju = 0;
        public Form6WolnePokoje()
        {
            InitializeComponent();
            for(int i=0;i<Form1Manager.klienci.Count;i++)
            {
                
                pokoje.Add(Form1Manager.klienci[i].getNr_pokoju());
                
            }
            int ile = 0;
            pokoje.Sort();
            if (pokoje.Count != 0)
            {
                for (int i = 1; i < 50; i++)
                {
                    if (i != pokoje[ile])
                    {
                        listBox1.Items.Add("Nr pokoju :" + (i));
                    }
                    else
                        if (ile < pokoje.Count - 1)
                            ile++;
                }
                listBox1.SelectedIndex = 0;
            }
            else
            {
                MessageBox.Show("Wszystkie pokoje sa wolne", "Informacja");
                for (int i = 1; i < 50; i++)
                {
                    listBox1.Items.Add("Nr pokoju :" + (i));
                }
                listBox1.SelectedIndex = 0;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void Form6WolnePokoje_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.Hide();
        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            
            string[] d = listBox1.Items[listBox1.SelectedIndex].ToString().Split(':');
            nrpokoju = int.Parse(d[1]);
            form2.Show();
            this.Hide();
        }

        private void Form6WolnePokoje_Load(object sender, EventArgs e)
        {

        }
    }
}
